//
//  NoticeData.m
//
//  Created by lianchuang  on 14-12-17
//  Copyright (c) 2014 __MyCompanyName__. All rights reserved.
//

#import "NoticeData.h"


NSString *const kNoticeDataAuthor = @"author";
NSString *const kNoticeDataDateline = @"dateline";
NSString *const kNoticeDataUid1 = @"uid1";
NSString *const kNoticeDataPic = @"pic";
NSString *const kNoticeDataAvatar = @"avatar";
NSString *const kNoticeDataUsername1 = @"username1";
NSString *const kNoticeDataMessage = @"message";
NSString *const kNoticeDataUid2 = @"uid2";
NSString *const kNoticeDataUrl = @"url";
NSString *const kNoticeDataPmid = @"pmid";
NSString *const kNoticeDataUsername2 = @"username2";
NSString *const kNoticeDataIsReaded = @"isReaded";

NSString *const kNoticeDataIsPcid = @"pcid";
NSString *const kNoticeDataIsRecvuid = @"recvuid";
NSString *const kNoticeDataIsRecvusername = @"recvusername";
NSString *const kNoticeDataIsSubject = @"subject";
NSString *const kNoticeDataIsSummary = @"summary";
NSString *const kNoticeDataIsTid = @"tid";
NSString *const kNoticeDataIsType = @"type";
NSString *const kNoticeDataIsUid =@"uid";
NSString *const kNoticeDataIsUsername = @"username";
NSString *const kNoticeDataIsPid = @"pid";


@interface NoticeData ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation NoticeData

@synthesize author = _author;
@synthesize dateline = _dateline;
@synthesize uid1 = _uid1;
@synthesize pic = _pic;
@synthesize avatar = _avatar;
@synthesize username1 = _username1;
@synthesize message = _message;
@synthesize uid2 = _uid2;
@synthesize url = _url;
@synthesize pmid = _pmid;
@synthesize username2 = _username2;
@synthesize isReaded = _isReaded;


@synthesize pcid = _pcid;
@synthesize recvuid = _recvuid;
@synthesize recvusername = _recvusername;
@synthesize subject = _subject;
@synthesize tid = _tid;
@synthesize type = _type;
@synthesize uid = _uid;
@synthesize username = _username;
@synthesize summary = _summary;
@synthesize pid = _pid;



+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
        self.author = [self objectOrNilForKey:kNoticeDataAuthor fromDictionary:dict];
        self.dateline = [self objectOrNilForKey:kNoticeDataDateline fromDictionary:dict];
        self.uid1 = [self objectOrNilForKey:kNoticeDataUid1 fromDictionary:dict];
        self.pic = [self objectOrNilForKey:kNoticeDataPic fromDictionary:dict];
        self.avatar = [self objectOrNilForKey:kNoticeDataAvatar fromDictionary:dict];
        self.username1 = [self objectOrNilForKey:kNoticeDataUsername1 fromDictionary:dict];
        self.message = [self objectOrNilForKey:kNoticeDataMessage fromDictionary:dict];
        self.uid2 = [self objectOrNilForKey:kNoticeDataUid2 fromDictionary:dict];
        self.url = [self objectOrNilForKey:kNoticeDataUrl fromDictionary:dict];
        self.pmid = [self objectOrNilForKey:kNoticeDataPmid fromDictionary:dict];
        self.username2 = [self objectOrNilForKey:kNoticeDataUsername2 fromDictionary:dict];
        self.isReaded = [self objectOrNilForKey:kNoticeDataIsReaded fromDictionary:dict];
        
        self.pcid = [self objectOrNilForKey:kNoticeDataIsPcid fromDictionary:dict];
        self.recvuid = [self objectOrNilForKey:kNoticeDataIsRecvuid fromDictionary:dict];
        self.recvusername = [self objectOrNilForKey:kNoticeDataIsRecvusername fromDictionary:dict];
        self.subject = [self objectOrNilForKey:kNoticeDataIsSubject fromDictionary:dict];
        self.tid = [self objectOrNilForKey:kNoticeDataIsTid fromDictionary:dict];
        self.type = [self objectOrNilForKey:kNoticeDataIsType fromDictionary:dict];
        self.uid = [self objectOrNilForKey:kNoticeDataIsUid fromDictionary:dict];
        self.username = [self objectOrNilForKey:kNoticeDataIsUsername fromDictionary:dict];
        self.summary = [self objectOrNilForKey:kNoticeDataIsSummary fromDictionary:dict];
        self.pid = [self objectOrNilForKey:kNoticeDataIsPid fromDictionary:dict];


        
        
        
        
        
        
        

    }
    
    return self;
    
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.author = [aDecoder decodeObjectForKey:kNoticeDataAuthor];
    self.dateline = [aDecoder decodeObjectForKey:kNoticeDataDateline];
    self.uid1 = [aDecoder decodeObjectForKey:kNoticeDataUid1];
    self.pic = [aDecoder decodeObjectForKey:kNoticeDataPic];
    self.avatar = [aDecoder decodeObjectForKey:kNoticeDataAvatar];
    self.username1 = [aDecoder decodeObjectForKey:kNoticeDataUsername1];
    self.message = [aDecoder decodeObjectForKey:kNoticeDataMessage];
    self.uid2 = [aDecoder decodeObjectForKey:kNoticeDataUid2];
    self.url = [aDecoder decodeObjectForKey:kNoticeDataUrl];
    self.pmid = [aDecoder decodeObjectForKey:kNoticeDataPmid];
    self.username2 = [aDecoder decodeObjectForKey:kNoticeDataUsername2];
    self.isReaded = [aDecoder decodeObjectForKey:kNoticeDataIsReaded];
    
    self.pcid = [aDecoder decodeObjectForKey:kNoticeDataIsPcid];
    self.recvuid = [aDecoder decodeObjectForKey:kNoticeDataIsRecvuid];
    self.recvusername = [aDecoder decodeObjectForKey:kNoticeDataIsRecvusername];
    self.subject = [aDecoder decodeObjectForKey:kNoticeDataIsSubject];
    self.tid = [aDecoder decodeObjectForKey:kNoticeDataIsTid];
    self.type = [aDecoder decodeObjectForKey:kNoticeDataIsType];
    self.uid = [aDecoder decodeObjectForKey:kNoticeDataIsUid];
    self.username = [aDecoder decodeObjectForKey:kNoticeDataIsUsername];
    self.summary = [aDecoder decodeObjectForKey:kNoticeDataIsSummary];
    self.pid = [aDecoder decodeObjectForKey:kNoticeDataIsPid];



    
    
    
    
    

    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_author forKey:kNoticeDataAuthor];
    [aCoder encodeObject:_dateline forKey:kNoticeDataDateline];
    [aCoder encodeObject:_uid1 forKey:kNoticeDataUid1];
    [aCoder encodeObject:_pic forKey:kNoticeDataPic];
    [aCoder encodeObject:_avatar forKey:kNoticeDataAvatar];
    [aCoder encodeObject:_username1 forKey:kNoticeDataUsername1];
    [aCoder encodeObject:_message forKey:kNoticeDataMessage];
    [aCoder encodeObject:_uid2 forKey:kNoticeDataUid2];
    [aCoder encodeObject:_url forKey:kNoticeDataUrl];
    [aCoder encodeObject:_pmid forKey:kNoticeDataPmid];
    [aCoder encodeObject:_username2 forKey:kNoticeDataUsername2];
    [aCoder encodeObject:_isReaded forKey:kNoticeDataIsReaded];
    
    [aCoder encodeObject:_pcid forKey:kNoticeDataIsPcid];
    [aCoder encodeObject:_recvuid forKey:kNoticeDataIsRecvuid];
    [aCoder encodeObject:_recvusername forKey:kNoticeDataIsRecvusername];
    [aCoder encodeObject:_subject forKey:kNoticeDataIsSubject];
    [aCoder encodeObject:_tid forKey:kNoticeDataIsTid];
    [aCoder encodeObject:_type forKey:kNoticeDataIsType];
    [aCoder encodeObject:_uid forKey:kNoticeDataIsUid];
    [aCoder encodeObject:_username forKey:kNoticeDataIsUsername];
    [aCoder encodeObject:_summary forKey:kNoticeDataIsSummary];
    [aCoder encodeObject:_pid forKey:kNoticeDataIsPid];



    
    
    

}

- (id)copyWithZone:(NSZone *)zone
{
    NoticeData *copy = [[NoticeData alloc] init];
    
    if (copy) {

        copy.author = [self.author copyWithZone:zone];
        copy.dateline = [self.dateline copyWithZone:zone];
        copy.uid1 = [self.uid1 copyWithZone:zone];
        copy.pic = [self.pic copyWithZone:zone];
        copy.avatar = [self.avatar copyWithZone:zone];
        copy.username1 = [self.username1 copyWithZone:zone];
        copy.message = [self.message copyWithZone:zone];
        copy.uid2 = [self.uid2 copyWithZone:zone];
        copy.url = [self.url copyWithZone:zone];
        copy.pmid = [self.pmid copyWithZone:zone];
        copy.username2 = [self.username2 copyWithZone:zone];
        copy.isReaded = [self.isReaded copyWithZone:zone];
        
        copy.pcid = [self.pcid copyWithZone:zone];
        copy.recvuid = [self.recvuid copyWithZone:zone];
        copy.recvusername = [self.recvusername copyWithZone:zone];
        copy.subject = [self.subject copyWithZone:zone];
        copy.tid = [self.tid copyWithZone:zone];
        copy.type = [self.type copyWithZone:zone];
        copy.uid = [self.uid copyWithZone:zone];
        copy.username = [self.username copyWithZone:zone];
        copy.summary = [self.summary copyWithZone:zone];
        copy.pid = [self.pid copyWithZone:zone];




    }
    
    return copy;
}


@end
